package com.zx.auth.block.enums;

import lombok.Getter;

/**
 * <p>
 * description: OAuth2授权类型枚举 <br>
 * create: 2025-11-12 15:35
 * </p>
 *
 * @author
 */
@Getter
public enum AuthorizationGrantTypeEnum {
    /**
     * 授权码模式
     */
    AUTHORIZATION_CODE("authorization_code", "授权码模式"),

    /**
     * 客户端凭证模式
     */
    CLIENT_CREDENTIALS("client_credentials", "客户端凭证模式"),

    /**
     * 刷新令牌模式
     */
    REFRESH_TOKEN("refresh_token", "刷新令牌模式"),

    /**
     * 密码模式
     */
    PASSWORD("password", "密码模式"),

    /**
     * 隐式模式
     */
    IMPLICIT("implicit", "隐式模式");

    /**
     * 授权类型值
     */
    private final String value;

    /**
     * 授权类型描述
     */
    private final String description;

    AuthorizationGrantTypeEnum(String value, String description) {
        this.value = value;
        this.description = description;
    }

    /**
     * 根据值获取授权类型枚举
     *
     * @param value 授权类型值
     * @return 授权类型枚举
     */
    public static AuthorizationGrantTypeEnum getByValue(String value) {
        for (AuthorizationGrantTypeEnum grantType : values()) {
            if (grantType.value.equals(value)) {
                return grantType;
            }
        }
        return null;
    }
}